﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace IESN.BaseForms
{
    /// <summary>
    /// 界面收集类，用于收集已打开的界面
    /// </summary>
    public class FormCollection : IDictionary<string, BaseFrm>
    {
        private IDictionary<string, BaseFrm> _forms;
        public FormCollection()
        {
            this._forms = new Dictionary<string, BaseFrm>();
        }

        /// <summary>
        /// 添加界面
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        public void Add(string key, BaseFrm value)
        {
            this._forms.Add(key, value);
        }

        public bool ContainsKey(string key)
        {
            return this._forms.ContainsKey(key);
        }

        public ICollection<string> Keys
        {
            get { return this._forms.Keys; }
        }

        public bool Remove(string key)
        {
            return this._forms.Remove(key);
        }

        public bool TryGetValue(string key, out BaseFrm value)
        {
            return this._forms.TryGetValue(key, out value);
        }

        public ICollection<BaseFrm> Values
        {
            get { return this._forms.Values; }
        }

        public BaseFrm this[string key]
        {
            get
            {
                return this._forms[key];
            }
            set
            {
                this._forms[key] = value;
            }
        }

        public void Add(KeyValuePair<string, BaseFrm> item)
        {
            this._forms.Add(item);
        }

        public void Clear()
        {
            this._forms.Clear();
        }

        public bool Contains(KeyValuePair<string, BaseFrm> item)
        {
            return this._forms.Contains(item);
        }

        public void CopyTo(KeyValuePair<string, BaseFrm>[] array, int arrayIndex)
        {
            this._forms.CopyTo(array, arrayIndex);
        }

        public int Count
        {
            get { return this._forms.Count; }
        }

        public bool IsReadOnly
        {
            get { return this._forms.IsReadOnly; }
        }

        public bool Remove(KeyValuePair<string, BaseFrm> item)
        {
            return this._forms.Remove(item);
        }

        public IEnumerator<KeyValuePair<string, BaseFrm>> GetEnumerator()
        {
            return this._forms.GetEnumerator();
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return this._forms.GetEnumerator();
        }
    }
}
